// functionPage/pages/review/networkType/networkType.js
const app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        id: '',
        infoId: '',
        operatorid: '',
        operatorInfo: {},
        review: '',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log(options);
        this.setData({
            review: options.review || '',
            id: options.id,
            infoId: options.infoId,
            operatorid: options.operatorid,
        });
        this.getOperatorInfo(options.operatorid, options.infoId);
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},

    //再次编辑获取网络内容
    getOperatorInfo(id, infoId) {
        let _that = this;
        console.log(infoId);
        wx.request({
            url:
                app.globalData.rootPath +
                `cjMap/getFtOperatorInfoDetail?authId=${app.globalData.authId}&id=${id}&ftspeciallocationid=${infoId}`,
            method: 'GET',
            header: {
                'content-type': 'application/json',
            },
            success: function (res) {
                console.log(res.data.ftOperatorInfo);
                // 兼容录的错误数据
                let datas = res.data.ftOperatorInfo;
                if (datas.operatorinfo) {
                    let values = JSON.parse(datas.operatorinfo);
                    console.log(values);
                    values = Object.entries(values);
                    console.log(values);
                    datas.operatorinfo = values;
                }
                if (
                    res.data.ftOperatorInfo.createtime ==
                    res.data.ftOperatorInfo.updatetime
                ) {
                    res.data.ftOperatorInfo.coupdatetime = false;
                } else {
                    res.data.ftOperatorInfo.coupdatetime = true;
                }
                _that.setData({
                    operatorInfo: datas,
                });
            },
        });
    },
});
